/** 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package it.free.i;

import it.free.i.naming.JndiClassFactory;
import it.free.i.naming.NamingBuilder;

/** 
 * Application main factory
 * @author stefano
 */
public class SystemFactory implements Factory {

	public static final String CONTEXT = "cn=System";
	
	/**
	 * No need to make possible to create instances
	 * Singleton makes it private, no creation from outside
	 */
	public SystemFactory(){
		super();
	}
	
	/**
	 * Create a class by its FQ name
	 * @param name of the object to create
	 * @return an instance of the object
	 * @throws Exception
	 */
	public Object createObject(String name) throws Exception {
		
		String fullyQualifiedJndiName = NamingBuilder.buildLookupName(name, SystemFactory.CONTEXT);
		
		return JndiClassFactory.classForJndiName(fullyQualifiedJndiName);
	}

}
